package cn.itcast.match_

import scala.util.Random

/**
  * @Package cn.itcast.match_
  * @author KTL
  * @date 2021/2/28 0028 15:32
  * @version V1.0
  * @Copyright © 2015-04-29  One for each, and two for each
  */
class MathchDemo01 {
}
object CaseDemo{
  def main(args: Array[String]): Unit = {
    println("-----匹配字符串-----")
    val arry1=Array("hadoop","spark")
    val name: String = arry1(Random.nextInt(arry1.length))
    name match{
      case "hadoop"=>println("hadoop")
      case "spark"=>print("spark")
    }

    println("-----匹配类型-----")
    val arr2 = Array("hello",1,CaseDemo)
    val value: Any = arr2(Random.nextInt(arr2.length))
    value match{
      case s:String=>print(s"s:${s}是string类型")
      case i:Int=>print(s"i:${i}是Int类型")
      case o:CaseDemo.type=>print(s"${o}是caseDemo类型")
    }
    println("-----集合类型-----")
    println("-----样例类型-----")
  }
}